//
//  MenuViewController.m
//  IOS-1010
//
//  Created by Apple-10 on 15/10/20.
//  Copyright (c) 2015年 Apple-10. All rights reserved.
//

#import "MenuViewController.h"
#import "Define.pch"
#import "MListServiceViewController.h"
@interface MenuViewController ()

@end

@implementation MenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.menuArray = [NSArray arrayWithObjects:@"扫一扫",@"我的足迹",@"购买记录",@"我的钱包",@"收货地址",@"设置",@"跟新版本" ,nil];
    
    
    self.menuView.tableFooterView=[[UIView alloc]init];
    self.view.backgroundColor=[UIColor lightGrayColor];
    self.menuView.backgroundColor=[UIColor lightGrayColor];
    
    
    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, SCREENHEIGHT-40, 100, 50)];
    label.text=@"  10.0.10";
    label.textColor=[UIColor blackColor];
    [self.view addSubview:label];
    
    UIButton *imageLabel = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 60,60)];
    [self.view addSubview:imageLabel];
    [imageLabel setBackgroundImage:[UIImage imageNamed:@"logo2.png"] forState:UIControlStateNormal];
    [imageLabel setBackgroundImage:[UIImage imageNamed:@"logo2.png"] forState:UIControlStateHighlighted];
    
    imageLabel.layer.cornerRadius=imageLabel.bounds.size.width/2;
    imageLabel.layer.masksToBounds = YES;
    
    UILabel *namelabel=[[UILabel alloc]initWithFrame:CGRectMake(75,15, 100, 50)];
    namelabel.text=@"  Susan";
    namelabel.textColor=[UIColor blackColor];
    [self.view addSubview:namelabel];

    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.menuArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellStr = @"Cell";
    
    
    //根据上面的标签，从tableView的队列中寻找是否有能重用的UITableViewCell（单元格），该过程也是系统帮我们实现
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
    
    //没有在tableView中寻找到可以重用的单元格，则需要我们自己用代码实现创建新的单元格，创建的时候要把标签用上以备后边可以重复使用，创建单元格的方式是UITableViewCellStyleDefault（默认方式）
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
    }
    

    NSString *menu = (NSString *)[self.menuArray objectAtIndex:indexPath.row];
    ;
 
    cell.textLabel.text = menu;
    cell.backgroundColor=[UIColor lightGrayColor];
    
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 66;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row==5) {
        SetViewController *setPassword=[[SetViewController alloc]init];
        
        [self presentViewController:setPassword  animated:YES completion:nil];

    }else if(indexPath.row==0){
        MListServiceViewController *new=[[MListServiceViewController alloc]init];
        [self presentViewController:new animated:YES completion:nil];
    }
}



#pragma mark - ICSDrawerControllerPresenting

- (void)drawerControllerWillOpen:(ICSDrawerController *)drawerController
{
    self.view.userInteractionEnabled = NO;
}

- (void)drawerControllerDidOpen:(ICSDrawerController *)drawerController
{
    self.view.userInteractionEnabled = YES;
}

- (void)drawerControllerWillClose:(ICSDrawerController *)drawerController
{
    self.view.userInteractionEnabled = NO;
}

- (void)drawerControllerDidClose:(ICSDrawerController *)drawerController
{
    self.view.userInteractionEnabled = YES;
}


@end
